Skip to content

feat: Detect missing slippage validation in DeFi operations - #531

Merged
mijinummi merged 1 commit into
MDTechLabs:mainfrom
TochukwuJustice:fix-missing-slippage
Jun 23, 2026
Merged

feat: Detect missing slippage validation in DeFi operations#531
mijinummi merged 1 commit into
MDTechLabs:mainfrom
TochukwuJustice:fix-missing-slippage

Conversation

@TochukwuJustice

Copy link
Copy Markdown
Contributor

closes #331

##Summary of changes:
New Feature: Added MissingSlippageValidationRule, which utilizes lexical heuristics to identify DeFi operations (e.g., swap, add_liquidity) and verify that their signatures contain a slippage protection parameter (e.g., min_amount, min_out, limit).
Organization: Created a new defi module inside packages/rules/src/security/ to appropriately categorize DeFi-specific static analysis rules.
Exporting: Updated packages/rules/src/security/mod.rs and packages/rules/src/lib.rs to expose the new rule so it can be utilized by the primary scanning engine.
Testing: Added comprehensive unit tests confirming accurate detection of both protected and unprotected liquidity functions.

##Reason for the changes: Resolves Issue #331. Lack of slippage validation in AMM and DEX contracts leaves user transactions highly vulnerable to MEV sandwich attacks and front-running. This new security rule ensures that developers are proactively warned when critical DeFi operations fail to accept parameters denoting price slippage bounds.

- Created 'defi' module in security rules to group DeFi-related analysis
- Implemented 'MissingSlippageValidationRule' to flag swap/liquidity operations lacking slippage protection parameters
- Integrated the new rule into the main engine via 'lib.rs' exports
- Added comprehensive rustdoc comments explaining the logic and rationale
- Added 4 targeted unit tests verifying detection heuristics for missing slippage
@drips-wave

drips-wave Bot commented Jun 23, 2026

Copy link
Copy Markdown

@TochukwuJustice Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@mijinummi
mijinummi merged commit 0d77754 into MDTechLabs:main Jun 23, 2026
6 checks passed
@grantfox-oss grantfox-oss Bot mentioned this pull request Jun 23, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detect Missing Slippage Validation

2 participants